#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
#define rep(i, a, b) for (int i = (a); i <= (b); i++)
#define per(i, a, b) for (int i = (a); i >= (b); i--)
#define endl '\n'
const int N = 5e6 + 5;
const int MOD = 998244353;

int n, m;
ll fac[N], ifac[N];
ll fastpow(ll b, ll p) {
  ll res = 1;
  while (p) {
    if (p & 1) res = res * b % MOD;
    b = b * b % MOD;
    p >>= 1;
  }
  return res;
}
void init(int n) {
  fac[0] = 1;
  rep(i, 1, n) fac[i] = fac[i - 1] * i % MOD;
  ifac[n] = fastpow(fac[n], MOD - 2);
  per(i, n - 1, 0) ifac[i] = ifac[i + 1] * (i + 1) % MOD;
}
ll C(int n, int m) {
  if (m > n) return 0;
  ll res = fac[n] * ifac[m] % MOD * ifac[n - m] % MOD;
  return res;
}
int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  int t;
  cin >> t >> n;
  init(n);
  int res = 0;
  while (t--) {
    cin >> n >> m;
    res ^= C(n, m);
  }
  cout << res;
  return 0;
}